package com.xc.common.converter;

import lombok.extern.slf4j.Slf4j;
import org.codehaus.jackson.map.DeserializationConfig;
import org.codehaus.jackson.map.ObjectMapper;
import org.springframework.stereotype.Component;
/**
 *  忽略前端传入的对象中不存在的值
 *  方法一：在目标类上加注解@JsonIgnoreProperties
 *  方法二：写个objectmapper注入到MappingJacksonHttpMessageConverter中
 *  在 dispather servelet中配置bean
 * Created by xiongcan on 2018/2/28.
 */
@Slf4j
@Component
public class MyJsonMapper extends ObjectMapper {

    public MyJsonMapper(){
        log.info("找到不存在的值，忽略========================");
        //目标类中找不到json字符串中属性时直接忽略
        this.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false);

    }

}
